﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Fintech.Utils;

namespace ZOVNP.WinView
{
    class PlainOrdersTreePopulationStrategy : IOrdersTreePopulationStrategy
    {
        private readonly Guid _id;
        private readonly string _text;

        public PlainOrdersTreePopulationStrategy()
        {
            _id = new Guid("FB4B1D6D-3EB5-4195-A406-88BB08EDA786");
            _text = "Одним списком";
        }

        public Guid ID { get { return _id; } }
        public string Text { get { return _text; } }

        public void PopulateTree(TreeView treeView, IEnumerable<OrderNode> nodes)
        {
            var root = new TreeNode("Все заказы");
            treeView.Nodes.Add(root);

            nodes.OrderBy(n => n.Order.Number).ForEach(n => root.Nodes.Add(n));
            root.Expand();
        }

        public override string ToString()
        {
            return _text;
        }
    }
}
